// pages/collect/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    collectMsg:{},
     // 导航分类
     tabs:[
      {
        id:1,
        name:"商品收藏",
        isActive:true
      },
      {
        id:2,
        name:"品牌收藏",
        isActive:false
      },
      {
        id:3,
        name:"店铺收藏",
        isActive:false
      },{
        id:4,
        name:"我的足迹",
        isActive:false
      }
    ],
    // 商品列表
    goodList:[
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:1,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:2,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:3,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:4,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:5,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:6,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:7,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:8,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:9,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:10,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:11,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:12,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:13,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:14,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:15,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:16,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:17,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:18,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:19,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:20,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:21,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:22,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:23,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
      {
        img:"//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png",
        id:24,
        title:"日本进口冰箱密封保鲜盒果蔬收纳盒超大容量加厚食物干果储存盒",
        coin:"￥999"
      },
    ]
  },
  // 根据标题索引来激活选中 标题数据
  changeTitleByIndex(index){
    // 修改原数组
    let {tabs} = this.data
    tabs.forEach((v,i) => i===index?v.isActive=true:v.isActive=false);
    // 赋值
    this.setData({
      tabs
    })
  },
  handleTabsItemchange(e){
  console.log(e)
  // 1.获取点击的标题索引
  const {index} = e.detail
  // 2.激活标题样式
  this.changeTitleByIndex(index)
  // 3.重新发送请求  type=1 index=0
  // this.getOrders(index+1)
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const collect = wx.getStorageSync("collect");
    this.setData({
      collectMsg:collect[1]
    })
    console.log(this.data.collectMsg)
    
  },
  /**
  * 生命周期函数--监听页面显示
  */
  onShow: function () {
  // 获取token值
  const token = wx.getStorageSync("token");
  // 判断是否需要去获取授权页面获取token值
  if(!token){
    wx.navigateTo({
      url: '/pages/auth/index',
    });
    return
  }
  // 1.获取当前的小程序的页面栈-数组  长度最大是10页面 
  var Pages =  getCurrentPages();
  // console.log(Pages)
  // 2.数组中最大的索引就是当前页面
  let currentPage= Pages[Pages.length-1]
  // 3.获取url上type的值
  const {type} =currentPage.options
  // 4.激活选中页面标题 当type=1 index=0 
  this.changeTitleByIndex(type-1)
  // 5.后台获取数据
  // this.getOrders(type)
  },
  /**
  * 获取订单表数据
  */
  // getOrders(type){
  //   request({url:"/Getcata",data:this.QueryParams,head}).then(res => {
  //   // 获取总条数
  //   const total = res.msg.total
  //   // 计算总页数
  //   this.totalpages=Math.ceil(total/this.QueryParams.pagesize)
  //   // 拼接数据列表
  //   var newlist=this.data.goodList.concat(result.data)
  //   this.setData({
  //       // 赋值给商品列表
  //       OrdersList:newlist
  //     })
  //   // 关闭下拉刷新
  //   wx.stopPullDownRefresh()
  //   })
  // },
})